package com.baizhi.controller;

import com.baizhi.BzMallApplication;
import com.baizhi.entity.PmsCategory;
import com.baizhi.service.PmsCategoryService;
import com.baizhi.vo.CategoryListVo;
import com.baizhi.vo.CategoryVo;
import com.baizhi.vo.CategoryZTreeVo;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author yu
 */
@RestController
public class PmsCategoryController {
    @Autowired
    private PmsCategoryService pmsCategoryService;

    @GetMapping("/pmsCategories")
    public Map showAll(){
        List<CategoryVo> categoryVos = pmsCategoryService.showCategoryList();
        HashMap<String, Object> map = new HashMap<>();
        map.put("status","success");
        map.put("data",categoryVos);
        return map;
    }

    @GetMapping("/categories/ztree")
    public Map showZtree(){
        HashMap<String, Object> map = new HashMap<>();
        List<CategoryZTreeVo> categoryZTreeVos = pmsCategoryService.showCategoryZTreeList();
        map.put("status","success");
        map.put("data",categoryZTreeVos);
        return map;
    }

    @GetMapping("/categories/categoryList")
    public Map showCategoryListVos(){
        HashMap<String, Object> map = new HashMap<>();
        List<CategoryListVo> categoryListVos = pmsCategoryService.showCategoryListVos();
        map.put("status","success");
        map.put("data",categoryListVos);
        return map;
    }
}
